$(function () {
  function load() {
    $.ajax("./javascripts/data_detail.json", {
      dataType: "json",
    }).then(function (res) {
      render(res.data);
    });
  }
  function render(list) {
    var html = list
      .map(function (item) {
        return `<div class="goods_box">
        <div class="goods_img">
          <img class="lazyload" src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2228985605,2720940451&fm=26&gp=0.jpg"
            data-src="${item.path}"
            alt=""
          />
        </div>
        <p class="goods_title">${item.title}</p>
        <p class="goods_slog">${item.slog}</p>
        <p class="goods_price">
          <span class="cur_price">${item.cur_price}</span>
          <span class="old_price">${item.old_price}</span>
        </p>
        <a href="./detail.html" class="buy_goods_btn">查看详情</a>
      </div>`;
      })
      .join("");
    $(".goods_wrapper").html(html);
    lazyload();
  }
  load();
});